
package com.kedacom.ctsp.authority.dao;

import com.kedacom.ctsp.authority.entity.Person;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Person DAO接口
 *
 */
public interface PersonSqlDao extends JpaRepository<Person, String> {


    /**
     * 根据部门code获取，部门人员
     *
     * @param deptCode
     * @return
     */
    @Query(nativeQuery = true, value = "select p.id from person p,department d where d.code= ?1 and p.department_id = d.id")
    List getPersonIdsByDeptCode(String deptCode);


    /**
     * 根据personId，获取user id
     *
     * @param deptCode
     * @return
     */
    @Query(nativeQuery = true, value = "select id from user where person_id= ?1")
    List getUserIdByPersonId(String deptCode);
}

